home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Search.wfm
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 1/94
- *
- * UPDATED: 6/94
- *
- * REVISION: $Revision: 1.21 $
- *
- * VERSION: dBASE FOR WINDOWS 5.0
- *
- * DESCRIPTION: This form allows setting a filter on the items currently
- * viewed. It allows you to create a combination filter based
- * on the artist, title, price, release date, and media type
- * of the available items from the Musical Methods store.
- *
- * PARAMETERS: None
- *
- * CALLS: Music.cc (for custom pushbuttons)
- * Music.prg (procedure file)
- *
- * USAGE: DO Search.wfm && or
- *
- * local f
- * set procedure to Search.wfm
- * f = new SearchForm()
- * f.ReadModal()
- *******************************************************************************
- #include <Messdlg.h>
- #include "Music.h"
- set talk off
- set ldcheck off
-
- ** END HEADER -- do not remove this line*
- * Generated on 06/19/94
- *
- LOCAL f
- f = NEW SEARCHFORM()
- f.Open()
-
- CLASS SEARCHFORM OF FORM
- Set Procedure to Music.cc Additive
- this.MousePointer = 1
- this.ColorNormal = "R/W"
- this.Width = 60.35
- this.Top = 6.18
- this.Text = "Search"
- this.Left = 23.29
- this.OnSelection = CLASS::ONSELECTION
- this.Height = 8.71
- this.Minimize = .F.
- this.Maximize = .F.
- this.OnOpen = CLASS::ONOPEN
- this.HelpFile = ""
- this.HelpId = ""
-
- DEFINE RECTANGLE SEARCHRECT OF THIS;
- PROPERTY;
- ColorNormal "w*/r",;
- Width 57.97,;
- Top 0.50,;
- Text "",;
- Left 1.19,;
- Height 3.79,;
- Border .T.,;
- BorderStyle 1
-
- DEFINE NORMALTEXT FIELDTEXT OF THIS;
- PROPERTY;
- FontBold .F.,;
- Alignment 5,;
- ColorNormal "w*/r",;
- Width 9.35,;
- Top 1.01,;
- Text "Field:",;
- Left 1.87,;
- Height 1.26,;
- Border .F.
-
- DEFINE COMBOBOX FIELDCOMBO OF THIS;
- PROPERTY;
- Width 27.20,;
- DataSource "STRUCTURE",;
- Top 1.00,;
- ID 800,;
- Left 11.90,;
- Value "",;
- Height 1.18,;
- Style 2,;
- HelpFile "Music.hlp",;
- HelpID "Search Field",;
- StatusMessage "Select a field to search for. Press F1 for Help."
-
- DEFINE NORMALTEXT VALUETEXT OF THIS;
- PROPERTY;
- FontBold .F.,;
- Alignment 5,;
- ColorNormal "w*/r",;
- Width 9.35,;
- Top 2.47,;
- Text "Value:",;
- Left 1.87,;
- Height 1.24,;
- Border .F.
-
- DEFINE NORMALENTRY VALUEENTRY OF THIS;
- PROPERTY;
- ColorNormal "R/W",;
- StatusMessage "Enter a value to search for. Press F1 for help.",;
- Width 45.90,;
- Top 2.47,;
- Left 11.90,;
- Value " ",;
- Height 1.24,;
- HelpFile "Music.hlp",;
- HelpID "Search Value",;
- Border .T.,;
- ColorHighLight "R/W*",;
- Enabled .T.,;
- Function "!"
-
- DEFINE IMAGE LOGOIMAGE OF THIS;
- PROPERTY;
- Alignment 2,;
- Width 10.71,;
- DataSource "FILENAME SMLMUSIC.BMP",;
- Top 4.55,;
- Left 1.19,;
- Height 3.79
-
- DEFINE OKBUTTON SEARCHOKBUTTON OF THIS;
- PROPERTY;
- Width 14.11,;
- Top 6.50,;
- Left 28.56,;
- Height 1.50
-
- DEFINE CANCELBUTTON SEARCHCANCELBUTTON OF THIS;
- PROPERTY;
- Group .F.,;
- Width 14.11,;
- Top 6.50,;
- ID 0,;
- Left 44.20,;
- Height 1.50
-
- ****************************************************************************
- procedure OnOpen
- ****************************************************************************
- set procedure to music.prg additive
- do SetEnvironment
- set exact off
- form.tempIsOpen = .f. && necessary for knowing if temp
- && table is in use at closing time
- *******************************************************************************
- procedure OnSelection
-
- * Search for the record where searchField = searchValue
- * This procedure is called when the OK button is pressed in the Search form.
- *******************************************************************************
- param controlId
- private curTable,formName,field,value,searchForm,foundRecord,saveFilt,tagNo
-
- field = ALLTRIM(this.fieldCombo.value) && searchField
- value = ALLTRIM(this.valueEntry.value) && searchValue
- saveFilt = setto("filter")
- set filter to
- do case
- case controlId = 0 && Cancel was selected. Don't do anything
- if form.tempIsOpen
- use in temp
- endif
- this.Close()
- case empty(field)
- AlertMessage("No Field was selected, Try again","Alert")
- case empty(value)
- AlertMessage("No Value was specified, Try again", "Alert")
- otherwise
- curTable = alias()
- if .not. form.tempIsOpen
- use (curTable) in select() again alias temp
- form.tempIsOpen = .t.
- endif
- select temp
- set filter to &saveFilt && Same filter as main table
- go top
- *** convert value to type of key()
- value = iif(type(field) $ "NF",val(value),value)
- tagNo = tagno(field)
- if tagNo <> 0 .and. key(tagNo) = field && Tag for field exists
- set order to &field && Tags based on single field have field name
- seek value
- else
- locate for &field = value
- endif
- *** convert back to character type if necessary
- value = ALLTRIM(this.valueEntry.value) &&iif(type("value") $ "NF", str(value),value)
- foundRecord = recno()
- if .not. found()
- select &curTable
- if ConfirmationMessage(FormatStr("%1 %2 not found. Continue Search?",;
- proper(field),value),;
- "Confirmation") = NO
- use in temp
- this.Close()
- endif
- else
- select &curTable
- go foundRecord
- set message to FormatStr("%1 %2 was found.", proper(field),value)
- use in temp
- this.Close()
- endif
- endcase
-
- ENDCLASS
-
-
-
-